from django.db import models
from myappa.models import *
from datetime import datetime
# Create your models here.


# 菜单表 15
class MenusModel(models.Model):
    mname = models.CharField(max_length=100,default='',verbose_name='一级菜单名称')
    mpath = models.CharField(max_length=100,default='',verbose_name='菜单路径')
    sort = models.IntegerField(default=0,verbose_name='排序')
    m_img = models.CharField(max_length=200,default='',verbose_name='菜单图标')
    menu = models.ForeignKey('self',related_name='men',on_delete=models.CASCADE,null=True,blank=True,verbose_name='自关联')

    class Meta:
        db_table = 'tb_menus'
    def __str__(self):
        return self.mname


# 车辆信息表 16
class CarMessageModel(models.Model):
    car_type = models.CharField(max_length=100,default='',verbose_name='车辆类型')
    plate_number = models.CharField(max_length=100,default='',verbose_name='车牌号')
    state = models.IntegerField(default=0,verbose_name='0 闲置 1 工作')

    class Meta:
        db_table = 'tb_car'
    def __str__(self):
        return self.car_type


# 文件材料表 17
class DocumentationModel(models.Model):
    d_name = models.CharField(max_length=100,default='',verbose_name='材料名称')
    d_addr = models.CharField(max_length=100,default='',verbose_name='材料暂放位置')
    user = models.ForeignKey(UserModel,on_delete=models.CASCADE,verbose_name='责任人(用户表外键)')

    class Meta:
        db_table = 'tb_documentation'
    def __str__(self):
        return self.d_name


#  操作日志表 18
class OperationLogModel(models.Model):
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE, verbose_name='员工(用户表外键)')
    operation_action = models.CharField(max_length=100,default='',verbose_name='操作工作')
    operation_time = models.CharField(max_length=100,default=datetime.now,verbose_name='操作时间')

    class Meta:
        db_table = 'tb_operation'
    def __str__(self):
        return self.user_id


# 登录日志表 19
class LoginLogModel(models.Model):
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE, verbose_name='员工(用户表外键)')
    login_time = models.CharField(max_length=100,default=datetime.now,verbose_name='登录时间')
    login_ip = models.CharField(max_length=100,default='',verbose_name='登录IP')
    login_shebei = models.CharField(max_length=100,default='',verbose_name='登录设备')

    class Meta:
        db_table = 'tb_loginlog'
    def __str__(self):
        return self.user_id


# 收件箱 20


# 发件箱 21